package cn.piesat.scanning.service.impl;

import cn.piesat.scanning.dao.HtDynamicParameterDAO;
import cn.piesat.scanning.dto.HtDynamicParameterDTO;
import cn.piesat.scanning.service.HtDynamicParameterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 任务配置动态（算法）参数服务层接口的实现
 */
@Service("htDynamicParameterService")
public class HtDynamicParameterServiceImpl implements HtDynamicParameterService {

    @Autowired
    private HtDynamicParameterDAO htDynamicParameterDAO;

    /**
     * 根据任务ID查询任务配置的动态参数信息为map
     * @param taskId 任务ID
     * @return
     */
    @Override
    public Map<String, Object> findByDynamictaskId(String taskId) {
        Map<String, Object> map = new HashMap<>();
        List<HtDynamicParameterDTO> bytaskId = htDynamicParameterDAO.findBytaskId(taskId);
        if (!bytaskId.isEmpty()){
            map = new HashMap<>();
            for (HtDynamicParameterDTO dto: bytaskId) {
                map.put(dto.getParamKey(),dto.getParamVal());
            }
        }
        return map;
    }
}
